package kr.pe.asuraho;

import java.io.IOException;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class DBConn {
	private DBConn(){}
	
	private static SqlSession sqlSession;
	
	public static SqlSession getSqlSession(){
		if(sqlSession == null){
			try {
				sqlSession = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("resource/mybatis-config.xml")).openSession();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return sqlSession;

	}
	
	public static void close(){
		if(sqlSession != null){
			sqlSession.close();
		}
	}
}